package com.qzsoft.zhjd.machine.modules.machineinfo.service.impl;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qzsoft.jeemis.common.utils.ConvertDictUtils;
import com.qzsoft.zhjd.common.components.BaseServiceComponent;
import com.qzsoft.zhjd.machine.modules.machineinfo.dto.MachineDepreciationDto;
import com.qzsoft.zhjd.machine.modules.machineinfo.mapper.MachineDepreciationMapper;
import com.qzsoft.zhjd.machine.modules.machineinfo.service.MachineDepreciationService;

/**
 * @ClassName MachineDepreciationServiceImpl
 * @Description 设备折旧业务接口实现
 * @author linhuawei
 * @since 2021-11-17
 */
@Service
public class MachineDepreciationServiceImpl implements MachineDepreciationService {

    @Autowired
    private BaseServiceComponent baseServiceComponent;
    
    @Autowired
    private MachineDepreciationMapper machineDepreciationMapper;

    @Override
    public IPage<MachineDepreciationDto> page(Map<String, Object> params) {
        // 执行查询操作
        IPage<MachineDepreciationDto> page = baseServiceComponent.getPage(params, MachineDepreciationDto.class);
        page = machineDepreciationMapper.page(page, params);
        
        // 数据转化
        page.getRecords().forEach(item->{
            if(null != item) {
                item = ConvertDictUtils.formatDicData(item);
                item.count();
            }
        });
        return page;
    }

}
